﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Data;
using System.Data.SqlClient;
using Ultility;

namespace Entity
{
    public partial class Entity_CheckIn : Component
    {
        DBAccess _access = new DBAccess();
        public Entity_CheckIn()
        {
            InitializeComponent();
        }

        public Entity_CheckIn(IContainer container)
        {
            container.Add(this);

            InitializeComponent();
        }

        public DataSet _Select_All_RoomStatus(int thang, int nam, string roomtypeID)
        {
            
            SqlParameter[] para = {new SqlParameter("@month",SqlDbType.Int),
                                   new SqlParameter("@year",SqlDbType.Int),
                                   new SqlParameter("@roomTypeid",SqlDbType.NVarChar),
                                  };
            para[0].Value = thang;
            para[1].Value = nam;
            para[2].Value = roomtypeID;
            if (thang == 1 || thang == 3 || thang == 5 || thang == 7 || thang == 8 || thang == 10 || thang == 12)
                return _access._ExcuteQuery("sp_ThongKePhong31", para);
            else if (thang == 4 || thang == 6 || thang == 9 || thang == 11)
                return _access._ExcuteQuery("sp_ThongKePhong30", para);
            else if (nam % 100 != 0 && nam % 4 == 0)
                return _access._ExcuteQuery("sp_ThongKePhong29", para);
            else
                return _access._ExcuteQuery("sp_ThongKePhong28", para);
        }

        public bool _Insert_Room_details(string id, string roomId, int slPhong, string Ngaydat, string ngayTra, int Nguoilon, int treEm)
        {
            SqlParameter[] para = {new SqlParameter("@id",SqlDbType.Char),
                                   new SqlParameter("@roomid",SqlDbType.NVarChar),
                                   new SqlParameter("@slphong",SqlDbType.Int),
                                   new SqlParameter("@checkInday",SqlDbType.DateTime),
                                   new SqlParameter("@checkOutday",SqlDbType.DateTime),
                                   new SqlParameter("@slNguoilon",SqlDbType.Int),
                                   new SqlParameter("@slTreem",SqlDbType.Int),
                                  };
            para[0].Value = id;
            para[1].Value = roomId;
            para[2].Value = slPhong;
            para[3].Value = Ngaydat;
            para[4].Value = ngayTra;
            para[5].Value = Nguoilon;
            para[6].Value = treEm;
            return _access._ExcuteNonQuery("sp_add_checkIn", para);
        }

        public bool _Insert_RentForm_Details(string maNV, string datTruoc, int maKH, string id, string Tongtien)
        {
            SqlParameter[] para = {new SqlParameter("@EmployeeID",SqlDbType.NVarChar),
                                   new SqlParameter("@deposit",SqlDbType.Char),
                                   new SqlParameter("@customerID",SqlDbType.Int),
                                   new SqlParameter("@detailsID",SqlDbType.Char),
                                   new SqlParameter("@amount", SqlDbType.Char),
                                  };
            para[0].Value = maNV;
            para[1].Value = datTruoc;
            para[2].Value = maKH;
            para[3].Value = id;
            para[4].Value = Tongtien;
            return _access._ExcuteNonQuery("sp_add_rentform", para);
        }

        public DataSet _Select_CheckInInfo(string maKH)
        {
            SqlParameter[] para = {new SqlParameter("@id", SqlDbType.Char),};
            para[0].Value = maKH;
            return _access._ExcuteQuery("sp_Select_CheckInInfo", para);
        }

        public bool _Update_CheckInInfo(string id, string checkInday, string checkOutday, int slPhong, int slNguoiLon, int slTreEm, string datCoc, string tongTien)
        {
            SqlParameter[] para = {new SqlParameter("@id",SqlDbType.Char),
                                   new SqlParameter("@checkInday",SqlDbType.DateTime),
                                   new SqlParameter("@checkOutday",SqlDbType.DateTime),
                                   new SqlParameter("@slphong",SqlDbType.Int),
                                   new SqlParameter("@slNguoilon", SqlDbType.Int),
                                   new SqlParameter("@slTreem", SqlDbType.Int),
                                   new SqlParameter("@deposit", SqlDbType.Char),
                                   new SqlParameter("@amount", SqlDbType.Char),
                                  };    
            para[0].Value = id;
            para[1].Value = checkInday;
            para[2].Value = checkOutday;
            para[3].Value = slPhong;
            para[4].Value = slNguoiLon;
            para[5].Value = slTreEm;
            para[6].Value = datCoc;
            para[7].Value = tongTien;
            return _access._ExcuteNonQuery("sp_Update_CheckInIfo", para);

        }
    }
}
